#ifndef _TRANSMIT_MSDH_H_
#define _TRANSMIT_MSDH_H_

//#include "global_dec.h"
#include "../msdhAndUartHandle/global.h"
/**/
#ifndef MAX_MSDH_RX_LIST
	#define MAX_MSDH_RX_LIST	1024	// FIXME, rx array element num
#endif

#ifndef MAX_MSDH_TX_LIST
	#define MAX_MSDH_TX_LIST	 256	// FIXME, tx array element num
#endif

/*
 * point to msdh frame command code deal function
 */
//typedef unsigned short			(* func_cmd_code_deal)( unsigned char * prx, unsigned short len, unsigned char * ptx );
typedef unsigned short			(* func_cmd_code_deal)(H16MUP_4G01* entity, unsigned char* pCmd, unsigned char* pRsp);
/*
 * receive array node
 */
typedef struct
{
	unsigned int				src_port;

	unsigned short				len;
	unsigned char				frm[MAX_SIZE_MSDH];
}	t_frm_rx_node;

/*
 * transmit and send array node
 */
/*
typedef struct
{
	unsigned char				mode;	// see : protocol_msdh.h line 52-56

	unsigned int				dst_port;
	unsigned int				dst_addr;

	unsigned short				len;
	unsigned char				frm[MAX_SIZE_MSDH];
}	t_frm_tx_node;
*/
typedef struct
{
	unsigned char				mode;
	unsigned short				len;
	unsigned char				frm[MAX_SIZE_MSDH];
}	t_frm_tx_node;

/*
 * global variable
 */
extern t_frm_rx_node			g_msdh_rx_node;
extern t_frm_tx_node			g_msdh_tx_node;
extern unsigned char			g_msdh_tx_buff[MAX_SIZE_MSDH];

/*extern DATA_BUF			g_msdh_rx_node;
extern DATA_BUF			g_msdh_tx_node;
extern unsigned char			g_msdh_tx_buff[MAX_SIZE_MSDH];
*/
/*
 * global function
 */

// tx 
extern int						insert_msdh_to_tx_list	( unsigned char * pbuf, unsigned short len, unsigned int port, unsigned int addr, unsigned char mode );
extern int						get_msdh_from_tx_list	( t_frm_tx_node & node );
extern unsigned int				get_msdh_dst_port		( unsigned int dst_addr );

// rx
extern unsigned char *			receive_msdh_frame		( int ind, unsigned char * pbuf, unsigned short len, int be_whole );

// tick
extern void						set_drne_age			( unsigned short age_secs, int clr );
//extern void						transmit_msdh_tick		( func_cmd_code_deal func = NULL );
extern void transmit_msdh_tick(H16MUP_4G01* entity,func_cmd_code_deal func = NULL);
#endif
